﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Grizzy_X
{
    public partial class Layer_View : Form
    {
        public Layer_View()
        {
            InitializeComponent();
            for (int i = 0; i < Controller.MyMap.Layer_List.Count; i++)
            {
                LayercheckedListBox.Items.Add(Controller.MyMap.Layer_List[Controller.MyMap.Layer_Order[i]-1].Name.ToString());
            }
            for (int j = 0; j < Controller.MyMap.BaseMap_List.Count; j++)
            {
                LayercheckedListBox.Items.Add(Controller.MyMap.BaseMap_List[Controller.MyMap.Base_Order[j]-1].Name.ToString());
            }
            Select_All.Checked = false;
        }

        public bool[] Display;
        private void OKbutton_Click(object sender, EventArgs e)
        {
            Display = new bool[LayercheckedListBox.Items.Count];
            for (int i = 0; i < LayercheckedListBox.Items.Count;i++ )
            {
                if (LayercheckedListBox.GetItemChecked(i))
                    Display[i] = true;
                else
                    Display[i] = false;
            }
            this.Close();
        }

        
        private void Cancelbutton_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void Select_All_CheckedChanged(object sender, EventArgs e)
        {
            if (Select_All.Checked == true)
            {
                for (int i = 0; i < LayercheckedListBox.Items.Count; i++)
                {
                    LayercheckedListBox.SetItemChecked(i, true);
                }
            }
            else
            {
                for (int i = 0; i < LayercheckedListBox.Items.Count; i++)
                {
                    LayercheckedListBox.SetItemChecked(i, false);
                }
            }
        }
    }
}
